package com.test.mchelepesa.bean_rice.user_info_rice;

import com.test.mchelepesa.util_rice.StringUtil_rice;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;

public class BankAccountList_rice {

    private static class Inner {
        private static final BankAccountList_rice instance = new BankAccountList_rice();
    }

    private BankAccountList_rice() {}

    public static BankAccountList_rice getInstance() {
        return Inner.instance;
    }

    private final ArrayList<Account> bankAccountList = new ArrayList<>();

    public static void parse(JSONArray jsonArray) {
        Gson gson = new Gson();
        Inner.instance.bankAccountList.clear();
        for (int i=0;i<jsonArray.length();i++){
            try {
                Account bankAccount = gson.fromJson(jsonArray.get(i).toString(), Account.class );
                Inner.instance.bankAccountList.add(bankAccount);
            } catch (JSONException e) {
                StringUtil_rice.printException(e);
            }
        }

    }

    public ArrayList<Account> getBankAccountList() {
        return bankAccountList;
    }

    public static class Account {

        private String id;
        private String walletMobile;
        private String walletLogo;
        private String walletDesc;

        public String getId() {
            return StringUtil_rice.getSafeString(id);
        }

        public String getWalletMobile() {
            return StringUtil_rice.getSafeString(walletMobile);
        }

        public String getWalletLogo() {
            return StringUtil_rice.getSafeString(walletLogo);
        }

        public String getWalletDesc() {
            return StringUtil_rice.getSafeString(walletDesc);
        }
    }

}
